Skip to content

Stop piping child process output into logger only after close#29967

Merged
ravicious merged 2 commits intomasterfrom
ravicious/child-logs
Aug 4, 2023
Merged

Stop piping child process output into logger only after close#29967
ravicious merged 2 commits intomasterfrom
ravicious/child-logs

Conversation

@ravicious
Copy link
Copy Markdown
Member

While working on the agent cleanup daemon (#29896), I noticed that for some reason we don't log stderr of a forked Node.js process if it fails right after forking.

After some investigation, I realized that by default sourceStream.pipe(destinationStream) closes the destination stream when the source stream closes.

Because we piped into the Wintston instance stream both stdout and stderr of a child process, it was entirely possible for the stdout to get closed first. This would close the Winston stream, not giving stderr a chance to log any of the flushed output.

This PR fixes this by closing the Winston instance stream only after both stdout and stderr get closed (as signaled by the close event).

It also improves the logging of the exit event – the previous implementation didn't log the signal.

@ravicious ravicious added teleport-connect Issues related to Teleport Connect. backport/branch/v11 labels Aug 3, 2023
@github-actions github-actions Bot requested review from gzdunek and ryanclark August 3, 2023 09:44
@ravicious ravicious force-pushed the ravicious/child-logs branch 2 times, most recently from d9f038f to 3c97d01 Compare August 3, 2023 10:48
This ensures we stop logging only after both stdout and stderr close,
not just either of them.
The previous implementation would log only the code.
@ravicious ravicious force-pushed the ravicious/child-logs branch from 3c97d01 to 79d678f Compare August 3, 2023 10:49
@ravicious ravicious added this pull request to the merge queue Aug 4, 2023
Merged via the queue into master with commit 39db3be Aug 4, 2023
@ravicious ravicious deleted the ravicious/child-logs branch August 4, 2023 08:37
@public-teleport-github-review-bot
Copy link
Copy Markdown

@ravicious See the table below for backport results.

Branch Result
branch/v11 Failed
branch/v12 Create PR
branch/v13 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/sm teleport-connect Issues related to Teleport Connect. ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants